﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
namespace Lawyer.Web.PostInfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtPostID.Text.Trim().Length==0)
			{
				strErr+="PostID不能为空！\\n";	
			}
			if(this.txtTile.Text.Trim().Length==0)
			{
				strErr+="Tile不能为空！\\n";	
			}
			if(this.txtDetail.Text.Trim().Length==0)
			{
				strErr+="Detail不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtStatus.Text))
			{
				strErr+="Status格式错误！\\n";	
			}
			if(this.txtCreatedBy.Text.Trim().Length==0)
			{
				strErr+="CreatedBy不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreatedDate.Text))
			{
				strErr+="CreatedDate格式错误！\\n";	
			}
			if(this.txtUpdatedBy.Text.Trim().Length==0)
			{
				strErr+="UpdatedBy不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUpdatedDate.Text))
			{
				strErr+="UpdatedDate格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string PostID=this.txtPostID.Text;
			string Tile=this.txtTile.Text;
			string Detail=this.txtDetail.Text;
			int Status=int.Parse(this.txtStatus.Text);
			string CreatedBy=this.txtCreatedBy.Text;
			DateTime CreatedDate=DateTime.Parse(this.txtCreatedDate.Text);
			string UpdatedBy=this.txtUpdatedBy.Text;
			DateTime UpdatedDate=DateTime.Parse(this.txtUpdatedDate.Text);

			Lawyer.Model.PostInfo model=new Lawyer.Model.PostInfo();
			model.PostID=PostID;
			model.Tile=Tile;
			model.Detail=Detail;
			model.Status=Status;
			model.CreatedBy=CreatedBy;
			model.CreatedDate=CreatedDate;
			model.UpdatedBy=UpdatedBy;
			model.UpdatedDate=UpdatedDate;

			Lawyer.BLL.PostInfo bll=new Lawyer.BLL.PostInfo();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
